<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>属性名：<input type="text" value="background" class="m"></p>
    <p>属性值：<input type="text" value="block" class="z"></p>
    <p><button class="but1">确定</button> <button class="but2">重置</button></p>
    <div class="bj">

    </div>
</body>

</html>
<style>
    .bj {
        width: 100px;
        height: 100px;
        background: #000;
    }

    p {
        margin-bottom: 10px;
    }
</style>
<script>
    var xxm = document.querySelector(".m")
    var xxz = document.querySelector(".z")
    var but1 = document.querySelector(".but1")
    var but2 = document.querySelector(".but2")
    var bj = document.querySelector(".bj")
    but1.onclick=function(){
        bj.style.backgroundColor=xxz.value
        console.log(xxz);
    }
    but2.onclick=function(){
        xxm.value="background"
        xxz.value="block"
        bj.style.backgroundColor="block"
    }
</script>